package com.itheima.common;

public class BaseContext {
    /**
     * 基于ThreadLocal封装工具类,用户保存和获取当前登录用户id
     * 将传递过来的id存入线程中
     */
    private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();
    private static Long ids;

    /**
     * 作用范围为某一个线程内,不会造成数据混乱
     * @param id
     */
    public static void setCurrentId(Long id){
        ids=id;
        threadLocal.set(id);
    }

    public static Long getCurrentId(){
        return ids;
    }
}
